# with open('./text/my_diary.txt','a',encoding = 'utf-8') as f:
#     f.write("\n日记写入完成")
#     print(f)


# data = input("今天的日期:")
# waether = input("今天的天气:")
# text = input("今天的心晴/总结:")
# with open('./text/my_diary.txt','a',encoding = 'utf-8') as f:
#     f.write(f"{data} {waether}\n")
#     f.write(text)
#     print(f)

#r+是读写
with open('./text/bill.txt','r+',encoding = 'utf-8') as f,open('./text/bill.txt.bak','w',encoding = 'utf-8') as f_bak:
    #备份
    res = f.read()
    f_bak.write(res)
    s = ""
    for line in res.split('\n'):
        if line.find('测试') == -1:
            s += line + '\n'
        
    #回转指针
    f.seek(0)
    #清空内容
    f.truncate()

    #写入新内容
    f.write(s)
